const db = require('../models');
const User = db.user;
// const Op = db.Sequelize.Op;

// 查询用户，检查登录
exports.findOne = (req, res) => {
  const { name, pwd } = req.body.data;
  console.log(name, pwd, req.body.data);
  User.findAll({ order: [['id', 'DESC']] }).then(data => {
    data.forEach(user => {
      if (user.dataValues.name === name && user.dataValues.pwd === pwd) {
        res.send({ token: '55sd2aa2f5a5r2a2df2a2d' })
      } else {
        res.send({
          code: 500,
          data: {
            stack: 'ss'
          },
          message: '服务异常'
        })
      }
    })
    console.log(data)
  })
}